﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.DwzFrame;
using NHibernate;
using ZLCMS.Data.Model;

namespace ZLCMS.Web.SystemManage.Template.Template
{
    public partial class TemplateList : System.Web.UI.Page
    {
        protected FrameHelper _framePage;
        protected void Page_Load(object sender, EventArgs e)
        {
            _framePage = new FrameHelper(this);


            int pageSize = _framePage.IsAjaxPagerPostBack ? _framePage.PageSize : 20;
            int pageIndex = _framePage.IsAjaxPagerPostBack ? _framePage.PageIndex : 1;
            using (ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
            {
                _framePage.RecordCount = Convert.ToInt32(session.CreateQuery("select count(*) from CmsTemplateInfo ").UniqueResult());

                repeater1.DataSource = session.CreateQuery("from CmsTemplateInfo order by Sort")
                    .SetMaxResults(pageSize)
                    .SetFirstResult((pageIndex - 1) * pageSize)
                    .List<CmsTemplateInfo>();
            }
            repeater1.DataBind();
        }
    }
}